
		*** Heterogeneity by Elementary and High school
	foreach h in 0 1 {

	eststo mlogit_3_high_school_`h': mlogit race_simple skin_color $ses $ind_vars grades_score ///
	if race < 4 & high_school == `h', cluster(class_id) b(3) difficult

	eststo mlogit_4_high_school_`h': mlogit race_simple skin_color i.class_id $ses $ind_vars ///
	grades_score ///
	if race < 4 & high_school == `h' , cluster(class_id) b(3) difficult

	}

	esttab mlogit_3_high_school_* mlogit_4_high_school_* , keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label mtitle nogaps ///
	indicate("Skin Color Dummies = *skin_color" "SES = score_neighborhood_quality" ///
	"Ind. Char. = score_self_esteem" "Class FE = *class_id")

	esttab mlogit_3_high_school_* mlogit_4_high_school_* ///
	using tables\mlogit_high_school, replace booktabs ///
	keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label nomtit ///
	indicate("Skin Color Dummies = *skin_color" "SES = scores_poverty" ///
	"Ind. Char. = score_self_esteem" "Class FE = *class_id")

	foreach j of numlist 3/4 {
		foreach h in 0 1 {
		
			est res mlogit_`j'_high_school_`h' 
			eststo mg_mlogit_`j'_high_school_1_`h': margins, predict(outcome(1)) dydx(grades_score) post 
			est res mlogit_`j'_high_school_`h' 
			eststo mg_mlogit_`j'_high_school_2_`h': margins, predict(outcome(2)) dydx(grades_score) post
			est res mlogit_`j'_high_school_`h' 
			eststo mg_mlogit_`j'_high_school_3_`h': margins, predict(outcome(3)) dydx(grades_score) post
		}
	}

	esttab 	mg_mlogit_3_high_school_1_* mg_mlogit_4_high_school_1_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_high_school_2_* mg_mlogit_4_high_school_2_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_high_school_3_* mg_mlogit_4_high_school_3_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle

	esttab 	mg_mlogit_3_high_school_1_* mg_mlogit_4_high_school_1_* ///
	using tables\mlogit_high_school_1 , replace booktabs ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_high_school_2_* mg_mlogit_4_high_school_2_* ///
	using tables\mlogit_high_school_2 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_high_school_3_* mg_mlogit_4_high_school_3_* ///
	using tables\mlogit_high_school_3 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 
	
		*** Heterogeneity by gender
	foreach h in 0 1 {

	eststo mlogit_3_m_`h': mlogit race_simple skin_color $ses $ind_vars grades_score ///
	if race < 4 & skin_color < 13 & skin_color > 1 & male == `h', cluster(class_id) b(3) difficult

	eststo mlogit_4_m_`h': mlogit race_simple skin_color i.class_id $ses $ind_vars ///
	grades_score ///
	if race < 4 & skin_color < 13 & skin_color > 1 & male  == `h' , cluster(class_id) b(3) difficult

	}

	esttab mlogit_3_m_* mlogit_4_m_* , keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label mtitle nogaps ///
	indicate("Skin Color Dummies = *skin_color" "SES = score_neighborhood_quality" ///
	"Ind. Char. = score_self_esteem" "Class FE = *class_id")

	esttab mlogit_3_m_* mlogit_4_m_* ///
	using tables\mlogit_gender, replace booktabs ///
	keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label nomtit ///
	indicate("Skin Color Dummies = *skin_color" "SES = scores_poverty" ///
	"Ind. Char. = score_self_esteem" "Class FE = *class_id")

	foreach j of numlist 3/4 {
		foreach h in 0 1 {
		
			est res mlogit_`j'_m_`h' 
			eststo mg_mlogit_`j'_m_1_`h': margins, predict(outcome(1)) dydx(grades_score) post 
			est res mlogit_`j'_m_`h' 
			eststo mg_mlogit_`j'_m_2_`h': margins, predict(outcome(2)) dydx(grades_score) post
			est res mlogit_`j'_m_`h' 
			eststo mg_mlogit_`j'_m_3_`h': margins, predict(outcome(3)) dydx(grades_score) post
		}
	}

	esttab 	mg_mlogit_3_m_1_* mg_mlogit_4_m_1_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_m_2_* mg_mlogit_4_m_2_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_m_3_* mg_mlogit_4_m_3_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle

	esttab 	mg_mlogit_3_m_1_* mg_mlogit_4_m_1_* ///
	using tables\mlogit_gender_1 , replace booktabs ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_m_2_* mg_mlogit_4_m_2_* ///
	using tables\mlogit_gender_2 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_m_3_* mg_mlogit_4_m_3_* ///
	using tables\mlogit_gender_3 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

		*** Heterogeneity by share of nonwhites
		
by ind_sh_nw_class, sort: sum sh_nw_class negro_na

	foreach h in 0 1 {

	eststo mlogit_3_s_`h': mlogit race_simple skin_color $ses $ind_vars grades_score ///
	if race < 4 & ind_sh_nw_class == `h', cluster(class_id) b(3)

	eststo mlogit_4_s_`h': mlogit race_simple skin_color i.class_id $ses $ind_vars ///
	grades_score ///
	if race < 4 & ind_sh_nw_class == `h' , cluster(class_id) b(3)

	}

	esttab mlogit_3_s_0 mlogit_3_s_1 mlogit_4_s_0 mlogit_4_s_1, keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label mtitle nogaps ///
	indicate("Skin Color Dummies = *skin_color" "SES = score_neighborhood_quality" ///
	"Ind. Char. = $ind_vars" "Class FE = *class_id")

	esttab mlogit_3_s* mlogit_4_s* ///
	using tables\mlogit_sh, replace booktabs ///
	keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label nomtit ///
	indicate("Skin Color Dummies = *skin_color" "SES = scores_poverty" ///
	"Ind. Char. = $ind_vars" "Class FE = *class_id")


	foreach j of numlist 3/4 {
		foreach h in 0 1 {
		
			est res mlogit_`j'_s_`h' 
			eststo mg_mlogit_`j'_s_1_`h': margins, predict(outcome(1)) dydx(grades_score) post 
			est res mlogit_`j'_s_`h' 
			eststo mg_mlogit_`j'_s_2_`h': margins, predict(outcome(2)) dydx(grades_score) post
			est res mlogit_`j'_s_`h' 
			eststo mg_mlogit_`j'_s_3_`h': margins, predict(outcome(3)) dydx(grades_score) post
		}
	}

	esttab 	mg_mlogit_3_s_1_* mg_mlogit_4_s_1_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_s_2_* mg_mlogit_4_s_2_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_s_3_* mg_mlogit_4_s_3_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle

	esttab 	mg_mlogit_3_s_1_* mg_mlogit_4_s_1_* ///
	using tables\mlogit_sh_1 , replace booktabs ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_s_2_* mg_mlogit_4_s_2_* ///
	using tables\mlogit_sh_2 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_s_3_* mg_mlogit_4_s_3_* ///
	using tables\mlogit_sh_3 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

		*** Heterogeneity by grades
	tab skin_color race if ind_grades == 1 
	tab skin_color race if ind_grades == 0
	
	foreach h in 0 1 {

	eststo mlogit_3_grades_`h': mlogit race_simple skin_color $ses $ind_vars grades_score ///
	if race < 4 & skin_color <=15 & skin_color > 0 & ind_grades  == `h', cluster(class_id) b(3) difficult

	eststo mlogit_4_grades_`h': mlogit race_simple skin_color $class_char i.school_id $ses $ind_vars ///
	grades_score ///
	if race < 4 & ind_grades  == `h' , cluster(class_id) b(3) difficult

	}

	esttab mlogit_3_grades* mlogit_4_grades* , keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label mtitle nogaps ///
	indicate("Skin Color Dummies = *skin_color" "SES = score_neighborhood_quality" ///
	"Ind. Char. = $ind_vars" "Class FE = *school_id")
	
	esttab mlogit_3_grades* mlogit_4_grades* ///
	using tables\mlogit_grades, replace booktabs ///
	keep(grades_score) noomit ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) compress label nomtit ///
	indicate("Skin Color Dummies = *skin_color" "SES = scores_poverty" ///
	"Ind. Char. = $ind_vars" "Class FE = *school_id")

	foreach j of numlist 3/4 {
		foreach h in 0 1 {
		
			est res mlogit_`j'_grades_`h' 
			eststo mg_mlogit_`j'_grades_1_`h': margins, predict(outcome(1)) dydx(grades_score) post 
			est res mlogit_`j'_grades_`h' 
			eststo mg_mlogit_`j'_grades_2_`h': margins, predict(outcome(2)) dydx(grades_score) post
			est res mlogit_`j'_grades_`h' 
			eststo mg_mlogit_`j'_grades_3_`h': margins, predict(outcome(3)) dydx(grades_score) post
		}
	}

	esttab 	mg_mlogit_3_grades_1_* mg_mlogit_4_grades_1_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_grades_2_* mg_mlogit_4_grades_2_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle
	esttab 	mg_mlogit_3_grades_3_* mg_mlogit_4_grades_3_* , ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) nogaps compress label nomtitle

	esttab 	mg_mlogit_3_grades_1_* mg_mlogit_4_grades_1_* ///
	using tables\mlogit_grades_1 , replace booktabs ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_grades_2_* mg_mlogit_4_grades_2_* ///
	using tables\mlogit_grades_2 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

	esttab 	mg_mlogit_3_grades_3_* mg_mlogit_4_grades_3_* ///
	using tables\mlogit_grades_3 , replace booktabs  ///
	b(3) se(3) star(* 0.1 ** 0.05 *** 0.01)  nogaps compress label nomtitle 

